<template>
	<view class="content">
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
		       userid :0
				
			}
		},
		onLoad:function (option) {
           //this.showlist()
		   console.log(option.paperId);
		   
		   //获取userID进行
		   this.userid=uni.getStorageSync("uservo")
		   console.log(this.userid)
		   if(this.userid ==0 ||this.userid == ''){
			   uni.reLaunch({
			   		url: '/pages/login/index',
			   	}); 
		   }
		   //获取一道题
		   this.startreview(this.qid)
		   
		   
		},
		methods: {
         //开始评测
		 startreview(qid){
			 console.log(11212122222222),
			 uni.request({
			     url: 'http://localhost:7020/review/topicsimplybyqid', //仅为示例，并非真实接口地址。
			    method: 'POST',
				 data: {
					 qid:qid
			     },
			     header: {
			         'custom-header': 'holler:' //自定义请求头信息
			     },
			     success: (res) => {
					 console.log('题来了')
					 if(res.data.code==200){
						 console.log(res.data.data)
						 this.topicTyple=res.data.data.topicTyple
						 this.quention=res.data.data
						 this.anwone=res.data.data.tbTopicAnswers
						 this.reload()
					 }else{
						 this.quention=null
						 this.anwone=null
						this.th=false
					 }
			     }
			 });
		 },
		 goto(){
			// getquentionbyid()
			console.log('答案：',this.aid,'题型',this.paperId)
			 this.startreview(this.quention.tid+1)
		 },
         //回答问题
		 getquentionbyid(userid,paperid,anowid){
			 uni.request({
			      url: 'https://localhost:7020/review/findtopicsimplybyqid',
			     data: {
			         qid: paperid
			     },
			     header: {
			         'custom-header': 'hello' //自定义请求头信息
			     },
			     success: (res) => {
			         console.log(res.data.code);
			         if(res.data.code==200){
						 console.log(res.data.data)
						 this.quention=res.data.data
					 }
			     }
			 });
		 },
		 //回答问题
		 quentiononanw(){
			 uni.request({
			     url: 'https://localhost:7010//request',
			     data: {
			         text: 'uni.request'
			     },
			     header: {
			         'custom-header': 'hello' //自定义请求头信息
			     },
			     success: (res) => {
			         console.log(res.data);
			         this.text = 'request success';
			     }
			 });
		 },
         //生成报告
		 toreport(userid,paperid){
			 uni.request({
			   url: 'https://localhost:7010//request',
			     data: {
			         text: 'uni.request'
			     },
			     header: {
			         'custom-header': 'hello' //自定义请求头信息
			     },
			     success: (res) => {
			         console.log(res.data);
			         this.text = 'request success';
			     }
			 });
		 }
		 
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
